/**
 * @author VernHe
 * @date 2021年10月24日 17:40
 */
public class Solution_0461 {
    public int hammingDistance(int x, int y) {
        int result = 0;
        if (x == y) {
            return result;
        }
        int tempX = x & 1;
        int tempY = y & 1;
        x = x >> 1;
        y = y >> 1;
        if (tempX != tempY) {
            result++;
        }
        while (x != 0 || y != 0) {
            if (x != 0) {
                tempX = x & 1;
                x = x >> 1;
            } else {
                tempX = 0;
            }
            if (y != 0) {
                tempY = y & 1;
                y = y >> 1;
            } else {
                tempY = 0;
            }
            if (tempX != tempY) {
                result++;
            }
        }

        return result;
    }

    public static void main(String[] args) {
        System.out.println(new Solution_0461().hammingDistance(1, 4));
    }
}
